package com.aaa.controller.sds;

import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;
import com.aaa.entity.sds.QuestionSds;
import com.aaa.entity.sds.TestPlanSds;
import com.aaa.service.sds.TestPlanSdsService;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 测试计划fpa(TestPlanSds)表控制层
 *
 * @author makejava
 * @since 2022-09-01 20:23:18
 */
@RestController
@RequestMapping("testPlanSds")
public class TestPlanSdsController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private TestPlanSdsService testPlanSdsService;


    /**
     * @param pageSortEntity
     * @param testPlanSds
     * @return
     * @create by: 张恒
     * @description: 查询
     * @create time: 2022/9/1 21:01
     */
    @RequestMapping("queryTestPlanSds.do")
    public Result queryTestPlanSds(PageSortEntity pageSortEntity, TestPlanSds testPlanSds) {
        Page page = testPlanSdsService.queryTestPlanSdsPage(pageSortEntity, testPlanSds);
        return success(page.getResult(), page.getTotal());
    }

    /**
     * @param testPlanSds
     * @return
     * @create by: 张恒
     * @description: 添加
     * @create time: 2022/9/1 21:05
     */
    @RequestMapping("saveTestPlanSds.do")
    public Result saveTestPlanSds(TestPlanSds testPlanSds) {
        boolean b = testPlanSdsService.insertTestPlanSds(testPlanSds);
        if (b) {
            return success();
        } else {
            return fail();
        }
    }

    /**
     * @param id
     * @return
     * @create by: 张恒
     * @description: 删除
     * @create time: 2022/9/1 21:06
     */
    @RequestMapping("deleteTestPlanSds.do")
    public Result deleteTestPlanSds(Integer[] id) {
        boolean b = testPlanSdsService.deleteTestPlanSdsById(id);
        if (b) {
            return success();
        } else {
            return fail();
        }
    }

    /**
     * @param testPlanSds
     * @return
     * @create by: 张恒
     * @description: 修改
     * @create time: 2022/9/1 21:08
     */
    @RequestMapping("updateTestPlanSds.do")
    public Result updateTestPlanSds(TestPlanSds testPlanSds) {
        boolean b = testPlanSdsService.updateTestPlanSds(testPlanSds);
        if (b) {
            return success();
        } else {
            return fail();
        }
    }

    /**
     * @param testPlanSds
     * @return
     * @create by: 张恒
     * @description: 唯一校验
     * @create time: 2022/9/1 21:10
     */
    @GetMapping("repetitionName.do")
    public Result repetitionName(TestPlanSds testPlanSds) {
        boolean b = testPlanSdsService.repetitionName(testPlanSds);
        if (b) {
            return success("计划名可用");
        } else {
            return fail("计划名重复或为空,不可用");
        }
    }
}

